//
//  MCCameraCompressHandle.m
//  CreditGroup
//
//  Created by ltl on 15/9/13.
//  Copyright (c) 2015年 JPlay. All rights reserved.
//

#import "MCCameraCompressHandle.h"

@implementation MCCameraCompressHandle

+ (UIImage *)imageCompressWith:(CGSize)size image:(UIImage *)image
{
    if (size.width == 0 && size.height == 0) {
        return image;
    }
    
    UIGraphicsBeginImageContext(size);
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    [image drawInRect:rect];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

+ (NSData *)imageDataWithJEPG:(UIImage *)image quality:(CGFloat)value
{
    return UIImageJPEGRepresentation(image, value);
}
+ (NSData *)imageDataWithPNG:(UIImage *)image
{
    return UIImagePNGRepresentation(image);
}
@end
